package main

import (
	"fmt"
	"strconv"
	"strings"
	"unicode"
)

func ssss() {
	s := "34 这 是一  段汉 字dft"

	fmt.Println(len(s))
	fmt.Println(len([]rune(s)))
	fmt.Println(s[0:3])
	fmt.Println(string([]rune(s)[1]))

	r := []byte(s)

	fmt.Println(string(r[3:]))

	line := "røde og gule sløjfer"
	line = "år 　 tørt\u2028vær"
	line = s

	i := strings.Index(line, " ")

	firstWord := line[:i]

	j := strings.LastIndex(line, " ")

	lastWord := line[j:]

	fmt.Println(firstWord, lastWord)

	i = strings.IndexFunc(line, unicode.IsSpace)
	firstWord = line[:i]

	j = strings.LastIndexFunc(line, unicode.IsSpace)
	lastWord = line[j:]

	fmt.Println(firstWord, lastWord)
}

func doprint() {
	type polar struct {
		radius, o float64
	}

	p := polar{8.32, .49}

	fmt.Print(-18.5, 17, "Elephant ", -8+.7i, 0x3c7, '\u03c7', "a", "b", p)

	fmt.Println()

	fmt.Println(-18.5, 17, "Elephant ", -8+.7i, 0x3c7, '\u03c7', "a", "b", p)

	fmt.Printf("%t %t \n", true, false)
	b, _ := strconv.ParseBool("1")
	fmt.Printf("%t %t \n", b, false)

}

//格式化整数
func doprint2() {
	fmt.Printf("|%b|%9b|%-9b|%09b|% 9b|\n", 37, 37, 37, 37, 37)

	fmt.Printf("|%o|%#o|%# 8o|%#+ 8o|%+08o|\n", 41, 41, 41, 41, -41)
}

func main() {
	doprint2()
}
